﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Liya.Crm.IService;
using Liya.Crm.Data;
using Liya.Crm.Data.Models;
using Liya.Crm.Core;

namespace Liya.Crm.Service
{
    public class Company : ICompany
    {
        public int SaveCompanyInfo(Sys_Company entity)
        {
            using (var repository = new Repository<Sys_Company>())
            {
                repository.Add(entity);
                if (repository.SaveDbChange() > 0)
                {
                    return entity.CId;
                }
                else
                {
                    return 0;
                }
            }
        }

        public int UpdateCompanyInfo(Sys_Company entity)
        {
            using (var repository = new Repository<Sys_Company>())
            {
                repository.Update(entity);
                if (repository.SaveDbChange() > 0)
                {
                    return entity.CId;
                }
                else
                {
                    return 0;
                }
            }
        }
    }
}
